package ynh.bis.actions;

import java.util.Vector;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import ynh.bis.beans.AjaxBean;
import ynh.bis.model.AjaxDAO;
import ynh.bis.util.StringUtil;

public class AjaxAction extends Action {
	

	public ActionForward execute(ActionMapping mapping , ActionForm form ,HttpServletRequest request , HttpServletResponse response) throws Exception{
		
		ActionForward forward = null;
		String district_id = (String)request.getParameter("district_id");
		String buscompay_id = (String)request.getParameter("buscompay_id");
		
		AjaxDAO dao = new AjaxDAO();
		
		if(!StringUtil.isEmpty(district_id)){
			
			Vector<AjaxBean> list = dao.getBusCompanyList(district_id);

			request.setAttribute("isSuccess","YES");  
			request.setAttribute("list",list); 
			request.setAttribute("district_id", district_id);
			request.setAttribute("buscompay_id", buscompay_id);
			
		}else{

			request.setAttribute("isSuccess","NO");  
			
		}

		

		forward = mapping.findForward("success");
		return forward;
	}

}
